<template>
  <div class="yao">
    <div class="input">
      <input placeholder="请输入想要查询的药理" @click="gosearch">
      <span class="sousuo" @click="gosearch">搜索</span>
    </div>



    <div class="item" v-for="(item,index) in list" :key="index">
      <!-- 一级 -->
      <div class="head">
        <div class="head-l">
          {{item.name}}
        </div>
      </div>
      <!-- 二级 -->
      <div class="zhong">
        <div :class="secondClass == ind && item.show == true?'active':''" v-for="(ite,ind) in item.sons" :key="ind" @click="getsecond(index,ind,ite)" v-show="ind < 9 || brandFold">
          {{ite.name}}
        </div>
      </div>

      <div class="foot" @click="isOpen(index)" v-if="item.sons.length > 9">
        <img :src="brandFold && item.show == true?'../../../static/meiyougengduo.png':'../../../static/gengduo.png'" alt="">{{brandFold && item.show == true?'收起':'查看更多'}}
      </div>

    </div>
    
  </div>
</template>

<script>
  export default {
    data() {
      return {
        brandFold:false,
        // 药品查询分类
        list:'',
        firstid:'',
        secondid:'',
        secondClass:-1,
      }
    },
    created() {
      this.getlist()
    },
    mounted(){
      
    },
    methods: {
      // 药品查询分类
      getlist(){
        this.$get("api/gzh_index.php?action=yaoli_list", {
        
        }).then(res => { 
          this.list = res.data
          for(var a in this.list){
            this.list[a].show=false
          }
        }).catch(err => {
          
        });
      },
      // 查看更多   收起
      isOpen(index){
        this.brandFold = !this.brandFold
        for(var a in this.list){
          if(a == index){
            this.list[a].show=true
          }else{
            this.list[a].show=false
          }
        } 
      },
      // 获取二级id   展示三级数据
      getsecond(index,ind,list){
        this.firstid = list.parent_id
        this.secondid = list.id
        this.secondClass = ind
        this.$router.push({
          name:'pathology-query-list',
          query: {secondid:this.secondid}
        }) 
      },
      // 跳转药理搜索
      gosearch(){
        this.$router.push({
          name:'yaoli-search'
        }) 
      },
    },
  }
</script>

<style scoped>
.yao{
  width: 100%;
}
.input {
  width: 100%;
  height: 140px;
  padding: 0 30px;
  box-sizing: border-box;
  position: relative;
  background: #db4949;
}
.input input{
  width: 590px;
  height: 73px;
  border-radius: 10px;
  outline:none;
  padding: 0 10px;
  border: none;
  background: #fff;
  box-sizing: border-box;
  margin-top: 30px;
  font-size:26px;
  font-family:PingFang SC;
  font-weight:500;
  
}
.sousuo{
  font-size: 28px;
  color: #fff;
  margin-left: 15px;
} 

.item{
  width: 100%;
  padding: 0 30px;
  box-sizing: border-box;
  margin-top: 30px;
  margin-bottom: 30px;
}
.head{
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.head-l{
  font-size: 38px;
  color: #333;
  font-weight: bold;
}
.zhong{
  margin-top: 36px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  text-align: center;
}
.zhong .active{
  background: #db4949;
  color: #fff;
  border: 1PX solid #db4949;
}
.zhong div{
  /* width: 210px; */
  height: 58px;
  margin-top: 10px;
  font-size: 28px;
  color: #3a3a3a;
  border: 1PX solid #ccc;
  line-height: 58px;
  box-sizing: border-box;
  margin-right: 40px;
  padding:  0 20px;
}
.zhong div img{
  width: 9px;
  height: 17px;
  margin-left: 10px;
}
.foot{
  width: 100%;
  margin-top: 20px;
  font-size: 26px;
  text-align: center;
}
.foot img{
  width: 20px;
  height: 10px;
  margin-right: 10px;
  vertical-align:middle;
}




</style>